package iterator;

import lombok.Data;

@Data
public class IteratorImpl implements Iterator{
    //数据存储
    private Object[] objects;
    //游标位置
    private int position;

    public IteratorImpl(Object[] objects) {
        this.objects = objects;
    }

    @Override
    public Object next() {
        System.out.println("当前游标位置："+position);
        return objects[position++];
    }

    @Override
    public boolean hasNext() {
        if (position < objects.length){
            return true;
        }
        return false;
    }
}
